"""
语法: while
1, 初始化计数器变量
2, 判断条件
3, 在循环体中修改计数器

"""
# 1, 通过while循环 先把0~100 设计出来
# 2. 在通过定义一个 result 变量 来累加 循环值
# i = 0
# result = 0
# # while 判断
# while i <= 100:
#     # 让它累加
#     result = result + i
#     print(i)
#     # 修改计数器
#     i = i + 1
#
# print(result)

i = 0
result = 0
# while i <= 100:
#     result = result + i
#     # print(i)
#     i = i +1
# print(f"1~100累加和计算结果为:{result}")

for i in range(101):
    result = result + i
    print(i)

    i = i + 1
print(f"1~100累加和计算结果为:{result}")